import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:dailoz/utils/toast.dart';
import 'package:fluttertoast/fluttertoast.dart';

class NetWorkCheck {
  static void check() async {
    var result = await Connectivity().checkConnectivity();
    switch (result) {
      case ConnectivityResult.wifi:
        showToast("您正在使用wifi", gravity: ToastGravity.TOP);
        break;
      case ConnectivityResult.mobile:
        showToast("您正在使用移动网络", gravity: ToastGravity.TOP);
        break;
      case ConnectivityResult.none:
        showToast("您暂未联网，请连接网络", gravity: ToastGravity.TOP);
        break;
      case ConnectivityResult.bluetooth:
        // TODO: Handle this case.
        break;
      case ConnectivityResult.ethernet:
        // TODO: Handle this case.
        break;
      case ConnectivityResult.vpn:
        // TODO: Handle this case.
        break;
      case ConnectivityResult.other:
        // TODO: Handle this case.
        break;
    }
  }
}
